import javax.swing.plaf.nimbus.NimbusLookAndFeel;
import java.util.Stack;

public class test {
    public int evalRPN(String[] tokens) {
        Stack<Integer> stack = new Stack<>();

        for (int i = 0; i < tokens.length; i++) {
            String tmp = tokens[i];
            if(!isOpearation(tmp)){
                Integer val = Integer.valueOf(tmp);
                stack.push(val);
            }else{
                Integer val2 = stack.pop();
                Integer val1 = stack.pop();
                switch(tmp){
                    case "+":
                        stack.push(val1 + val2);
                        break;
                    case "-":
                        stack.push(val1 - val2);
                        break;
                    case "*":
                        stack.push(val1 * val2);
                        break;
                    case "/":
                        stack.push(val1 / val2);
                        break;
                }
            }
        }
        return stack.pop();
    }


    public boolean isOpearation(String s){
        if(s.equals("+") || s.equals("-") || s.equals("*") || s.equals("/")){
            return true;
        }
        return false;
    }
}
